package com.starinside.wp.domain.record;

import com.starinside.wp.domain.Domain;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;

/**
 * *******************************
 * Created by Tim.
 * form com.matt
 * on 2017/8/3
 * *******************************
 */
@Data
@Entity
@Table(name = "birthday_record")
@EqualsAndHashCode(callSuper = true)
public class BirthdayRecord extends Domain {

    @Column(columnDefinition = " varchar(50) COMMENT '题目' ")
    private String title;

    @Column(columnDefinition = " varchar(1024) COMMENT '内容' ")
    private String content;

    @Column(columnDefinition = " int default 1 COMMENT '媒体类型 1：图片，2:video' ")
    private Integer type;

    @Column(columnDefinition = " varchar(2048) COMMENT '媒体文件地址' ")
    private String resourceUrl;

    @Column(columnDefinition = " varchar(1024) COMMENT '预览图地址' ")
    private String thumbUrl;

    @Column(columnDefinition = " varchar(32) COMMENT '上传人id' ")
    private String operatorId;

    @Column(columnDefinition = " varchar(50) COMMENT '上传人姓名' ")
    private String operatorName;


    public static BirthdayRecord of(String title, String content, Integer type, String resourceUrl, String thumbUrl, String operatorId, String operatorName) {
        BirthdayRecord birthdayRecord = new BirthdayRecord();
        birthdayRecord.setTitle(title);
        birthdayRecord.setContent(content);
        birthdayRecord.setType(type);
        birthdayRecord.setResourceUrl(resourceUrl);
        birthdayRecord.setThumbUrl(thumbUrl);
        birthdayRecord.setOperatorId(operatorId);
        birthdayRecord.setOperatorName(operatorName);
        birthdayRecord.setCreated(new Date());
        return birthdayRecord;
    }
}
